import { RoleNotFindError } from "../class/errors";
import { Role, RoleSubClass } from "../class/Role";
import { TangSan } from "../roles/唐三";
import { SengLongQiShi } from "../roles/圣龙骑士";
import { XiaoWu } from "../roles/小舞";
import { ZhanShen·ARuiSi } from "../roles/战神·阿瑞斯";
import { WuMingCiKe } from "../roles/无名刺客";
import { JiGuangShengYi } from "../roles/极光圣翼";
import { GouTouCeHuaQingShui } from "../roles/狗头策划清水";
import { ZhuNengChi } from "../roles/猪能吃";
import { JingGangLang } from "../roles/金刚狼";
import { AXiuLuo } from "../roles/阿修罗";
import { MaHongJun } from "../roles/马红俊";
import { DefaultRole } from "../roles/默认角色";
import { FeiZhiLongEr } from "../roles/龙之飞儿";

/**
 * 角色工厂
 */
export class RoleFactory {
    private static RoleList: typeof Role[] = [TangSan, MaHongJun, ZhuNengChi, DefaultRole, WuMingCiKe, JingGangLang, XiaoWu, FeiZhiLongEr, SengLongQiShi, JiGuangShengYi, GouTouCeHuaQingShui, ZhanShen·ARuiSi, AXiuLuo];
    public static getByName(name: string) {
        const _RoleSubClass = this.RoleList.find(e => e.roleName === name);
        if (_RoleSubClass === undefined) {
            throw new RoleNotFindError();
        } else {
            return _RoleSubClass as unknown as typeof RoleSubClass;
        }
    }
    /** 判断是否有交 ruleName 这个名字的角色 */
    public static hasRole(ruleName: string) {
        return this.RoleList.find(e => e.roleName === ruleName) !== undefined;
    }
    /** 添加一个角色到工厂里来，这样这个角色才能正常运转 */
    public static add(roleOption: typeof RoleSubClass) {
        this.RoleList.push(roleOption);
    }
    /** 获取所有角色名字 */
    public static getAllRoleNames() {
        return this.RoleList.map(RoleClass => RoleClass.roleName);
    }
}
